<template>
  <div>
    <!-- <div style="margin-left:30px"> -->
    <div style="float:right;margin-right:3px">
      <div class="toolbar">
        <el-button type="text" size="medium" icon="el-icon-document-add" @click="checkAndOpenAddDialog" v-if="!disableSave">新增</el-button>
      </div>
    </div>
    <!--表格渲染-->
    <el-table class="tl-table" ref="mainTable" :height="200" v-loading="loading" :data="datas" @selection-change="doSelectChange" @sort-change="doSortChange" @row-dblclick="doRowDbClick" @row-click="doRowClick" row-key="id" border fit :row-class-name="doChangeRowClassName">
      <el-table-column type="index" label="序号" width="55px" align="center"></el-table-column>
      <el-table-column prop="dispcategory" label="分类" width="100px" sortable="custom" sort-by="category" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="scoreitem" label="评分项" width="150px" sortable="custom" sort-by="scoreitem" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="totalvalue" label="总分值" width="150px" sortable="custom" sort-by="totalvalue" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="ourscore" label="我司得分" width="150px" sortable="custom" sort-by="ourscore" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="losescorereason" label="失分原因分析" min-width="200px" sortable="custom" sort-by="losescorereason" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="description" label="备注" min-width="100px" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column label="操作" width="80px" v-slot="scope" fixed="right">
        <el-dropdown trigger="hover">
          <el-button type="text" icon="el-icon-s-operation" style="margin-left:10px">更多<i class="el-icon-arrow-down el-icon--right"></i></el-button>
          <el-dropdown-menu>
            <el-dropdown-item icon="el-icon-view" @click.native="openEditDialog('editForm', scope.row.id)">编辑</el-dropdown-item>
            <el-dropdown-item icon="el-icon-delete" @click.native="doDelete(scope.row.id)">删除</el-dropdown-item>
            <el-dropdown-item icon="el-icon-view" @click.native="openViewDialog('editForm', scope.row.id)">查看</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </el-table-column>
    </el-table>
    <tl-edit ref="editForm" @refresh="doRefresh" :reviewModel="model"></tl-edit>
  </div>
</template>

<script>
/** mixins */
import { mixin_list } from '@tapui/mixins/mixin_list'
/** 子组件 */
import tlEdit from './edit'
/** 工具类 */
import { getAction, putAction, postAction, deleteAction } from '@tapui/utils/http'
export default {
  name: 'mpmProjectReviewBidDetail',
  mixins: [mixin_list],
  components: { tlEdit },
  data() {
    return {
      description: '项目复盘结项-评标细则-列表查询',
      urlPrefix: '/mpm/projectReviewBidDetail/',
      url: {
        // queryCodeList: '/mpm/projectReviewBidDetail/dataCodeList'
      },
      // 排序参数
      sorterInfo: {
        sidx: 'sortcode',
        sord: 'asc'
      },
      isQueryOnCreated: false
    }
  },
  props: {
    disableSave: {
      default: false,
      type: Boolean
    },
    model: {
      default: function () {
        return {}
      },
      type: Object
    }
  },
  methods: {
    checkAndOpenAddDialog() {
      // 判断父组件model.id是否有值
      if (this.model.id) {
        this.openAddDialog('editForm')
      } else {
        this.$tap
          .confirm('新增评标细则前需要先保存项目复盘申请单，是否保存？')
          .then((_) => {
            // 调用父组件保存，保存成功后打开弹框
            this.$emit('saveAndOpenBidDetailDialog')
          })
          .catch((_) => { })
      }
    },
    beforeLoadData() {
      if (!this.model.id) {
        return false
      }
      this.queryParam.parentid = this.model.id
      return true
    }
  }
}
</script>

<style scoped></style>

